<?php
namespace app\user\controller;
use think\Controller;
use app\user\model\Users;

class Register extends Controller
{
    public function index(){
        return view('register');
    }

    public function register()
    {
        $uses = new Users();
        $user = input('user');
        $user = str_replace(' ', '', $user);
        $pwd = input('pwd');
        $pwd = password_hash($pwd, PASSWORD_BCRYPT);
        $reg_date = date("Y-m-d H:i:s");

        $uses->data([
            'user' => $user,
            'pwd' => $pwd,
            'reg_date' => $reg_date,
            'score'=>100,
            'photo'=>"/public/static/pic/avatar/default.gif"
        ]);
        if ($uses->save()) {
            return 'success';
        } else {
            return $uses->getError();
        }
    }
}